#include <iostream>
#include <vector>
#include <chrono>

int main() {
    const int n = 30000000;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = i + 1;
    }

    auto start = std::chrono::high_resolution_clock::now();

    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
    }

    auto end = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> elapsed = end - start;

    std::cout << "数组元素的总和为：" << sum << std::endl;
    std::cout << "计算耗时：" << elapsed.count() << " 秒" << std::endl;

    return 0;
}

